<template>
	<gui-page :customHeader="true" :headerClass="['gui-bg-green']" :full-page="true" :isHeaderSized="false">
		<template v-slot:gHeader>
			<view style="height: 44px" class="gui-flex gui-nowrap gui-rows gui-align-items-center">
				<view class="" style="width: 130rpx">
					<gui-header-leading :home="false" :backButtonClass="['gui-color-white']"></gui-header-leading>
				</view>
				<text class="gui-bold gui-flex1 gui-text-center gui-ellipsis gui-color-white" style="margin-bottom: 5rpx; font-size: 16px">种子详情</text>
				<view style="width: 130rpx" @click="toHistory">
					<view class="gui-text gui-color-white">历史记录</view>
				</view>
			</view>
		</template>
		<template v-slot:gBody>
			<view class="gui-padding">
				<view class="gui-h5 gui-bold">种子信息</view>
				<view class="gui-bg-white gui-padding gui-border-radius gui-margin-top">
					<view class="gui-flex gui-space-between">
						<view class="gui-color-gray">入库编号：{{dataRec.detailInfo.orderno}}</view>
						<view class="gui-primary-color">{{dataRec.detailInfo.kuwei_title}}</view>
					</view>
					<view class="gui-h5 gui-bold gui-margin-top">{{dataRec.detailInfo.title}}</view>
					<view class="gui-border-radius gui-bg-grey7 gui-flex gui-space-between" style="margin-top:20rpx;padding: 26rpx 20rpx;">
						<view class="gui-text-center">
							<view class="gui-text gui-color-grey1 gui-text-small">种子分类</view>
							<view class="gui-text gui-color-black gui-text-small" style="margin-top: 10rpx;">{{dataRec.detailInfo.zhiliang_title}}</view>
						</view>
						<view class="gui-text-center">
							<view class="gui-text gui-color-grey1 gui-text-small">箱号</view>
							<view class="gui-text gui-color-black gui-text-small" style="margin-top: 10rpx;">{{dataRec.detailInfo.xianghao}}</view>
						</view>
						<view class="gui-text-center">
							<view class="gui-text gui-color-grey1 gui-text-small">数量</view>
							<view class="gui-text gui-color-black gui-text-small" style="margin-top: 10rpx;">{{dataRec.detailInfo.num}}粒</view>
						</view>
						<view class="gui-text-center">
							<view class="gui-text gui-color-grey1 gui-text-small">重量</view>
							<view class="gui-text gui-color-black gui-text-small" style="margin-top: 10rpx;">{{dataRec.detailInfo.weight}}g</view>
						</view>
					</view>
													
					<view class="">
						<view class="gui-form-item gui-border-b">
							<text class="gui-form-label gui-secondary-text">出库量</text>
							<view class="gui-form-body">
								<input type="text" class="gui-form-input" v-model="dataRec.num" placeholder="请输入" />
							</view>
							<text class="gui-text gui-color-red1">扣除</text>
						</view>
						<view class="gui-form-item gui-border-b">
							<text class="gui-form-label gui-secondary-text">重量</text>
							<view class="gui-form-body">
								<input type="text" class="gui-form-input" v-model="dataRec.weight" placeholder="请输入" />
							</view>
							<text class="gui-text gui-color-red1">矫正</text>
						</view>
						<view class="gui-form-label gui-secondary-text">出库用途</view>
						<view class="">
							<view class="gui-bg-gray" style="padding: 14rpx">
								<textarea v-model="dataRec.remark" placeholder="请输入出库用途" class="gui-textarea gui-bg-gray" style="width: 100%"></textarea>
							</view>
						</view>
					</view>
				</view>
				<view class="" style="margin-top: 60rpx">
					<button @click="releaseBtn" type="default" class="gui-button gui-bg-primary gui-noborder gui-border-radius-large">
						<text class="gui-color-white gui-button-text">保存</text>
					</button>
				</view>
			</view>
		</template>
	</gui-page>
</template>
<script setup>
import { Local } from '@utils/storage.js';
import graceJS from '@/Grace6/js/grace.js';
import imgArr from '@assets/js/export.js';
import { detailApi,detail_baocunApi } from '@api/repertory.js';
import { reactive, ref, toRefs, onMounted, onActivated } from 'vue';
import { onShow,onLoad } from '@dcloudio/uni-app';

let imgArrRec = reactive(imgArr);
let dataRec = reactive({
	detailInfo:{},
	num: '',
	weight: '',
	remark: ''
});
let toHistory = () => {
	uni.navigateTo({
		url:"/pages/repertory/repertoryHistory?id="+dataRec.detailInfo.id
	})
}
let releaseBtn = async() => {
	let req = {
		id:dataRec.detailInfo.id,
		num:dataRec.num,
		weight:dataRec.weight,
		remark:dataRec.remark
	}
	let res = await detail_baocunApi(req);
	if(res.code==1){
		uni.showToast({
			title:"保存成功",
			icon:'none'
		})
		setTimeout(()=>{
			uni.navigateBack()
		},200)
	}
	console.log(res)
};
onLoad(async (e) => {
	let res = await detailApi({id:e.id});
	dataRec.detailInfo = res.data;
});
</script>
<style lang="scss" scoped>
page {
	background-color: #fafafa;
}
</style>
